< previous page page_401 next page >

Page 401
Table 20.3 Methods of the TextStream Class.
MethodDescription
CloseFileCloses the file when youre through with it. This method is also called from the Class_Terminate() event.
OpenTextFileOpens a file for reading or appending. Youll pass in the filename and the mode for opening the file.
ReadLineReads a line of data from the text file up to but not including the carriage return and linefeed characters.
WriteLineWrites a line of data to the text file with a carrigage return and line feed placed onto the end of the line.

Lets look at the how you would use the TextStream class in an application. Ive left out a lot of the error handling just to keep the examples short and understandable; however, in a production application, you would want to have the appropriate error handling in all of these routines.
Writing to a File Using the TextStream Class
Youll start out by learning how to write information from a text box into a text file. The form shown in Figure 20.3 has a text box in which you can type some text. It also has a text box that accepts a filename to write information into. After youve entered this text, the Write button can be clicked to put the information into the appropriate text file.
Examples Filename: FileWrite.frm
8160-0401a.gif
Figure 20.3
Writing to a text file using the 
TextStream class.

 
< previous page page_401 next page >

If you like this book, buy it!